﻿using B.S.BaseData.suyuan.InforStances.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B.S.BaseData.suyuan.InforStances.Implement
{
    public class BaseRepository<T>:IBaseRepository<T>where T : class
    {
        private readonly SCDbcontext dbcontext;

        public BaseRepository(SCDbcontext dbcontext)
        {
            this.dbcontext = dbcontext;
        }
        public Task<int> AddEntity(T entity) 
        {
            dbcontext.Add(entity);
            return dbcontext.SaveChangesAsync();
        }
        public Task<int> DeleEntity(T entity) 
        {
            dbcontext.Update(entity);
            return dbcontext.SaveChangesAsync();
        }
        public async Task<T> ShowEntity(long Id) 
        {
            return await dbcontext.Set<T>().FindAsync(Id);
        }
        public async Task<IQueryable<T>> IQueryEntity() 
        {
            return dbcontext.Set<T>();
        }

    }
}
